package cn.stylefeng.guns.modular.entity.responseVo;

import cn.stylefeng.guns.modular.entity.Device;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Setter
@Getter
public class DeviceListResponseVo {

    private Long deviceId;

    private String deviceNum;

    private String deviceType;

    private String companyName;

    private String workshopName;

    private Date createdAt;

    private String status;

    private String deviceName;

    public static DeviceListResponseVo fromDeviceListResponseVo(Device device, String companyName, String workshopName) {
        DeviceListResponseVo dlr = new DeviceListResponseVo();
        dlr.setDeviceId(device.getDeviceId());
        dlr.setDeviceNum(device.getDeviceNum());
        dlr.setDeviceType(device.getDeviceType());
        dlr.setCompanyName(companyName);
        dlr.setWorkshopName(workshopName);
        dlr.setCreatedAt(device.getCreatedAt());
        dlr.setDeviceName(device.getDeviceName());
        if (Strings.isNullOrEmpty(device.getDeviceQrcode())) {
            dlr.setStatus("未生成");
        } else {
            dlr.setStatus("已生成");
        }
        return dlr;
    }
}
